import nattyFetch from 'natty-fetch';

const { API_URL,MOCK_URL } = require(`./../config/${ENV}.json`);
const context = nattyFetch.context({
  mockUrlPrefix: MOCK_URL,
  urlPrefix: API_URL,
  mock: false,
  withCredentials: false,
  traditional: true,
  data: {
    _wx_token_: '',
  },
  timeout: 20000,
  // 请按照需要开启
  fit: function (response) {
    let ret = {
      success: response.success
    };
    if (ret.success) {
      ret.content = response.data;
    } else {
      ret.error = {
        message: response.msg
      }
    }
    return ret;
  }
});

context.create('WechatAPI', {

  //获取配置
  auth: {
    url: 'wechat/api/sign',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  //获取用户信息
  getUser: {
    mock: false,
    url: 'wechat/get/user',
    method: 'GET',
  },

  //绑定用户信息
  binding: {
    url: 'wechat/user/binding',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  uplogin: {
    url: 'wechat/sys/uplogin',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  filestream: {
    url: 'wechat/sys/filestream',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },


  //用户信息
  getPageUser: {
    url: 'wechat/user/page',
    method: 'GET',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  //绑定用户信息
  sendVcode: {
    url: 'wechat/message/vcode/send',
    method: 'GET'
  },

  //验证用户信息
  checkUserCertNum: {
    url: 'wechat/sys/checkCert',
    method: 'GET'
  },

  //已验证用户信息
  getUserForWechat: {
    url: 'wechat/sys/getwtuser',
    method: 'GET',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  //已验证用户信息
  getPersonForWechat: {
    url: 'wechat/sys/getwtcertuser',
    method: 'GET',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },


  //
  userIsBinding: {
    url: 'wechat/user/isBinding',
    method: 'GET'
  },

  //获取工程列表
  getEng: {
    method: 'GET',
    url: 'wechat/eng/page',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  },

  //获取工程
  getEngById: {
    method: 'GET',
    url: 'wechat/eng/engbyid',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  },


  //保存监理日志
  saveJlrizhiInfo: {
    url: 'wechat/jlrzjl/save',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  //上传监理日志
  upJlrizhiInfo: {
    url: 'wechat/jlrzjl/upload',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  //保存施工日志
  saveSgrizhiInfo: {
    url: 'wechat/sgrzjl/save',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  //上传施工日志
  upSgrizhiInfo: {
    url: 'wechat/sgrzjl/upload',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  //保存安全日志
  saveAqrizhiInfo: {
    url: 'wechat/aqrzjl/save',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  //上传安全日志
  upAqrizhiInfo: {
    url: 'wechat/aqrzjl/upload',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },
  //获取天气
  getTianQi: {
    url: 'wechat/tq/get',
    method: 'GET',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  },



  //获取日志
  findRiZhiList: {
    url: 'wechat/rzjl/page',
    method: 'GET',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  },

  //获取安全日志
  findAQRiZhiList: {
    url: 'wechat/aqrzjl/page',
    method: 'GET',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  },

  //获取监理日志
  findJLRiZhiList: {
    url: 'wechat/jlrzjl/page',
    method: 'GET',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  },

  //获取施工日志
  findSGRiZhiList: {
    url: 'wechat/sgrzjl/page',
    method: 'GET',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  },



  //获取施工日志
  findSGRiZhiControl: {
    url: 'wechat/sgrzjl/control',
    method: 'GET',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  },

  //获取监理日志
  findJLRiZhiControl: {
    url: 'wechat/jlrzjl/control',
    method: 'GET',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  },

  //获取安全日志
  findAQRiZhiControl: {
    url: 'wechat/aqrzjl/control',
    method: 'GET',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  },

  //获取安全日志
  findAQRZTest: {
    url: 'wechat/aqrzjl/page',
    method: 'GET',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  },

  //根据记录类型获取监督记录
  findJLDLByLxControl: {
    url: 'wechat/jl/jllx',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  },

  //根据多个记录类型获取监督记录
  findJLByLxMany: {
    url: 'wechat/jl/fcjllx',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  },

  //获取隐蔽报验
  findYBBYControl: {
    url: 'wechat/ybgcby/control',
    method: 'GET',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  },

  //保存隐蔽报验
  saveYBBYInfo: {
    url: 'wechat/ybgcby/save',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  //上传隐蔽报验
  upYBBYInfo: {
    url: 'wechat/ybgcby/upload',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  //获取隐蔽报验
  findYBBYList: {
    url: 'wechat/ybgcby/page',
    method: 'GET',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  },

  //获取竣工申请
  findJGSQControl: {
    url: 'wechat/jgyssq/control',
    method: 'GET',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  },

  //获取设备安装
  findSBAZList: {
    url: 'wechat/shebeiaz/page',
    method: 'GET',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  },

  //获取设备安装
  findSBAZControl: {
    url: 'wechat/shebeiaz/control',
    method: 'GET',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  },

  //保存设备安装
  saveSBAZInfo: {
    url: 'wechat/shebeiaz/save',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  //获取整改回复通过关联ID
  findZGHFControlGl: {
    url: 'wechat/zghfjl/controlgl',
    method: 'GET',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  },

  //获取复工申请通过关联ID
  findFGSQControlGl: {
    url: 'wechat/fgsqjl/controlgl',
    method: 'GET',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  },


  //整改回复
  saveZGHFInfo: {
    url: 'wechat/zghfjl/save',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  //上传整改回复
  upZGHFInfo: {
    url: 'wechat/zghfjl/upload',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  //上传整改回复图片
  upZGHFInfoImg: {
    url: 'wechat/zghfjl/uploadimg',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  //复工申请
  saveFGSQInfo: {
    url: 'wechat/fgsqjl/save',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  //上传整改回复
  upFGSQInfo: {
    url: 'wechat/fgsqjl/upload',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  //获取竣工申请
  findJGSQList: {
    url: 'wechat/jgyssq/page',
    method: 'GET',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  },

  //保存竣工申请
  saveJGSQInfo: {
    url: 'wechat/jgyssq/save',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  //上传竣工申请
  upJGSQInfo: {
    url: 'wechat/jgyssq/upload',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  //上传设备安装
  upSheBeiAzInfo: {
    url: 'wechat/shebeiaz/upload',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  //上传图片
  uploadMedia: {
    mock: false,
    url: 'wechat/upload/uploadMedia',
    method: 'POST',
    fit: function (response) {
      let ret = {
        success: true
      };
      if (ret.success) {
        ret.content = response;
      }
      else {
        ret.error = {
          message: response.msg
        }
      }
      return ret;
    }
  },

  //图片信息
  getImgFileUrl: {
    mock: false,
    url: 'wechat/img/getFiles',
    method: 'GET',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },

  //图片保存关联
  saveImgFileUrl: {
    url: 'wechat/img/saveFiles',
    method: 'POST',
    header: {
      'Content-Type': 'application/json;charset=utf-8'
    },
  },



});


export default context.api;
